const { ccclass, property } = cc._decorator;

@ccclass
export default class CardDebugPanel extends cc.Component {
    static Instance: CardDebugPanel;

    @property(cc.Node)
    Button_close: cc.Node = null;
    @property(cc.Node)
    main: cc.Node = null;
    @property(cc.Node)
    parent: cc.Node = null;

    list: any[] = new Array();

    static CurrentSelectIndex: number = -1;
    static CurrentSelectId: number = -1;

    onLoad() {
        CardDebugPanel.Instance = this;

        this.main.active = false;
    }

    start() {
        this.Button_close.on(
            "click",
            () => {
                this.ShowOff();
            },
            this
        );

        // this.AddButtons();
    }

    Refresh() {
        console.log(`刷新`);
        // XXL_CommonFunction.SetAllChildrenAtive(this.parent, false);
        // const count: number = 8;
        // for (let index = 0; index <= count - 1; index++) {
        //     const id = index;
        //     // const itemdata = CardFunctions.Get_card_itemdata(id);

        //     // let child = XXL_CommonFunction.GetFreeChild(this.parent);
        //     // child.active = true;

        //     // const icon = cc.find("icon", child).getComponent(cc.Sprite);
        //     // console.log(`itemdata----------`, itemdata, itemdata.sprite);
        //     // console.log(`icon.name----------`, icon.name);
        //     // console.log(`icon----------`, icon);

        //     // icon.node.width = 78;
        //     // icon.node.height = 97;

        //     child.on(
        //         "click",
        //         () => {
        //             XXL_CardDebugPanel.CurrentSelectIndex = index;
        //             XXL_CardDebugPanel.CurrentSelectId = id;
        //             console.log(XXL_CardDebugPanel.CurrentSelectIndex, XXL_CardDebugPanel.CurrentSelectId);
        //         },
        //         this
        //     );
        // }
    }

    AddButtons() {
        this.list.push({
            title: "生成字索引成语表",
            callback: () => {
                // GameManager.GetList_word();
            },
        });

        this.list.push({
            title: "生成目标成语",
            callback: () => {
                console.log(`---------------------`);
            },
        });
    }

    ShowOn() {
        // this.node.active = true;
        this.main.active = true;
        this.Refresh();
    }

    ShowOff() {
        // this.node.active = false;
        this.main.active = false;
    }
}
